package _mst;

import _object.ListNode;

/**
 * 面试题 02.02. 返回倒数第 k 个节点
 */
public class T0202 {
    public int kthToLast(ListNode head, int k) {
        ListNode pre = head;
        for (int i = 0; i < k; i++) {
            pre = pre.next;
        }
        while (pre != null) {
            head = head.next;
            pre = pre.next;
        }
        return head.val;
    }
}
